//
//  YTBaseSelectStringView.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/7/22.
//

#import "YTBaseSelectStringView.h"


@interface YTBaseSelectStringView ()
@property (nonatomic ,strong) UILabel * forceFlagLab;
@property (nonatomic ,strong) UILabel * nameLab;
@property (nonatomic ,strong) UILabel * contentLab;
@property (nonatomic ,strong) UIView * makeview  ;
@property (nonatomic ,strong) UIImageView * rightimg;

@end

@implementation YTBaseSelectStringView
+ (instancetype)NewViewWithNil{
    YTBaseSelectStringView * view = [YTBaseSelectStringView NewView];
    [DTKTool YJ:0 andView:view.makeview];
    [view.makeview mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.bottom.offset(0);
    }];
    return view;
}
+ (instancetype)NewViewWithUP{
    YTBaseSelectStringView * view = [YTBaseSelectStringView NewView];
    [view.makeview mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.offset(0);
        make.bottom.offset(kwt(-10));
    }];
    return view;
}
+ (instancetype)NewView{
    YTBaseSelectStringView * view = [YTBaseSelectStringView new];
    view.backgroundColor = UIColor.whiteColor;
    view.clipsToBounds = YES;
    [view setupview];
    return view;
}
-(void)setMakeColor:(UIColor *)makeColor{
    self.makeview.backgroundColor = makeColor;
}

- (void)setupview{
    
    UIView * makeview = [UIView new];
    self.makeview = makeview;
    makeview.backgroundColor = KcolorHex(@"#F6F7F9");
    [DTKTool YJ:kwt(5) andView:makeview];
    [self addSubview:makeview];
    [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.offset(kwt(5));
        make.bottom.offset(kwt(-5));
    }];
    
    UILabel * forceFlagLab = [DTKTool labelWithText:@"*" andFont:kCFont(17) andTextColor:KcolorHex(@"#FA0F0F")];
    self.forceFlagLab = forceFlagLab;
    forceFlagLab.mas_KLS().mas_KYS();
    [makeview addSubview:forceFlagLab];
    [forceFlagLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(10));
        make.centerY.offset(0);
    }];
    
    UILabel * nameLab = [DTKTool labelWithText:@"--" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
    self.nameLab = nameLab;
    nameLab.mas_KLS().mas_KYS();
    [makeview addSubview:nameLab];
    [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(forceFlagLab.mas_right);
        make.centerY.offset(0);
    }];
    
    UIImageView * rightimg = kimageView(@"template_enter");
    self.rightimg = rightimg;
    [makeview addSubview:rightimg];
    [rightimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-10));
        make.centerY.offset(0);
        make.width.height.offset(kwt(15));
    }];
    
    UILabel * contentLab = [DTKTool labelWithText:@"请选择" andFont:kFont(18) andTextColor:KcolorHex(@"#787A79")];
    self.contentLab = contentLab;
    contentLab.textAlignment = NSTextAlignmentRight;
    [makeview addSubview:contentLab];
    [contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(nameLab.mas_right).offset(kwt(10));
        make.right.equalTo(rightimg.mas_left).offset(kwt(-8));
        make.centerY.offset(0);
    }];
    MJWeakSelf
    self.addClickBlock(^{
        [weakSelf viewclick];
    });
    
}
- (void)viewclick{
    if(self.block){
        self.block(self.content);
    }
}
- (void)setForceFlag:(BOOL)forceFlag {
    _forceFlag = forceFlag;
    if(forceFlag){
        self.forceFlagLab.text = @"*";
    } else {
        self.forceFlagLab.text = @"";
    }
}

- (void)setName:(NSString *)name{
    _name = name;
    self.nameLab.text = name;
}
-(void)setContent:(NSString *)content{
    _content = content;
    if(content.length > 0){
        self.contentLab.textColor = KcolorHex(@"#222222");
        self.contentLab.text = content;
    } else {
        self.contentLab.textColor = KcolorHex(@"#787A79");
        if(self.contentMRStr){
            self.contentLab.text = self.contentMRStr;
        }else {
            self.contentLab.text = @"请选择";
        }
    }
    if(self.NOClick){
        self.contentLab.textColor = KcolorHex(@"#888888");
    }
}
- (void)setNOClick:(BOOL)NOClick{
    _NOClick = NOClick;
    if(NOClick){
        self.makeview.backgroundColor = KcolorHex(@"#F0F0F0");
        self.nameLab.textColor = KcolorHex(@"#888888");
        self.rightimg.hidden = YES;
        self.contentLab.textColor = KcolorHex(@"#888888");
        [self.contentLab mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.nameLab.mas_right).offset(kwt(10));
            make.right.equalTo(self.rightimg);
            make.centerY.offset(0);
        }];
    }
}
- (void)setFont:(UIFont *)font{
    self.nameLab.font = font;
}
@end

@interface YTMinSelectStringView ()
@property (nonatomic ,strong) UILabel * contentLab;

@end

@implementation YTMinSelectStringView

+ (instancetype)NewViewWithLeft{
    YTMinSelectStringView * view = [YTMinSelectStringView new];
    view.backgroundColor = UIColor.whiteColor;
    view.clipsToBounds = YES;
    [view leftsetupview];
    return view;
}
- (void)leftsetupview{
    
    UILabel * contentLab = [DTKTool labelWithText:@"请选择" andFont:kFont(15) andTextColor:KcolorHex(@"#787A79")];
    self.contentLab = contentLab;
    contentLab.textAlignment = NSTextAlignmentLeft;
    [self addSubview:contentLab];
    [contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.left.offset(kwt(12));
    }];
    
    UIImageView * rightimg = kimageView(@"template_enter");
    [self addSubview:rightimg];
    [rightimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(contentLab.mas_right).offset(kwt(7));
        make.centerY.offset(0);
        make.width.height.offset(kwt(15));
        make.right.offset(kwt(-12));
    }];
    MJWeakSelf
    self.addClickBlock(^{
        [weakSelf viewclick];
    });
 
}
+ (instancetype)NewView{
    YTMinSelectStringView * view = [YTMinSelectStringView new];
    view.backgroundColor = UIColor.whiteColor;
    view.clipsToBounds = YES;
    [view setupview];
    return view;
}
- (void)setupview{
    
    UILabel * contentLab = [DTKTool labelWithText:@"请选择" andFont:kFont(15) andTextColor:KcolorHex(@"#787A79")];
    self.contentLab = contentLab;
    contentLab.textAlignment = NSTextAlignmentCenter;
    [self addSubview:contentLab];
    [contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.centerX.offset(kwt(-10));
        make.left.greaterThanOrEqualTo(@(kwt(6)));
    }];
    
    UIImageView * rightimg = kimageView(@"template_enter");
    [self addSubview:rightimg];
    [rightimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(contentLab.mas_right).offset(kwt(7));
        make.centerY.offset(0);
        make.width.height.offset(kwt(15));
    }];
    MJWeakSelf
    self.addClickBlock(^{
        [weakSelf viewclick];
    });
 
}
- (void)viewclick{
    if(self.block){
        self.block(self.content);
    }
}

-(void)setContent:(NSString *)content{
    _content = content;
    if(content.length > 0){
        self.contentLab.textColor = KcolorHex(@"#222222");
        self.contentLab.text = content;
    } else {
        self.contentLab.textColor = KcolorHex(@"#787A79");
        self.contentLab.text = @"请选择";
    }

}
- (void)setFont:(UIFont *)font{
    self.contentLab.font = font;
}
@end
